cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(recipe-08 LANGUAGES CXX)

message(STATUS "c++ compiler flags: ${CMAKE_CXX_FLAGS}")        # 最开始的C++编译标志

list(APPEND flags "-fPIC" "-Wall")
if (NOT WIN32)
    list(APPEND flags "-Wextra" "-Wpedantic")
endif ()
message(STATUS "c++ compiler flags: ${flags}")                  # 一个编译标志flag

add_library(geometry STATIC geometry_circle.hpp geometry_circle.cpp
                            geometry_polygon.hpp geometry_polygon.cpp
                            geometry_rhombus.hpp geometry_rhombus.cpp
                            geometry_square.hpp geometry_square.cpp)
target_compile_options(geometry PRIVATE ${flags})               # 这个库目标设置了编译选项

add_executable(compute-areas compute-areas.cpp)
target_compile_options(compute-areas PRIVATE "-fPIC")           # 这个库目标设置了编译选项
target_link_libraries(compute-areas geometry)